package com.zsrt.javaweb.bbu.book.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zsrt.javaweb.bbu.book.dao.BookShopDao;
import com.zsrt.javaweb.bbu.book.service.BookShopService;

@Service("bookShopService")
public class BookShopServiceImpl implements BookShopService {
	
	@Autowired
	private BookShopDao bookShopDao;

	@Override
	public void purchase(String username, int isbn) {
		
		//1 获取书的单价
		int price = bookShopDao.findBookPriceByIsbn(	isbn);
		
		//2 更新书的库存  -1
		bookShopDao.updateBookStock(	isbn);
		
		//3 更新用户余额  
		bookShopDao.updateUserAccount(username, price);

	}

}
